<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var arrayRankTransform = function(arr) {
				const map = {};
				Array.from(new Set(arr)).sort((a, b) => a - b).forEach((item, index) => {
					map[item] = index + 1
				});
				return arr.map(m => map[m])
			};
			console.log(arrayRankTransform([40, 10, 20, 30]));
			// console.log(arrayRankTransform([10, 10, 10]));
		</script>
	</body>
</html>
